package pers.cz.logtail.handle.adapter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pers.cz.logtail.connect.ConnectionFactory;
import pers.cz.logtail.connect.DBType;
import pers.cz.logtail.connect.IConnection;
import pers.cz.netty.protocal.Message;

import java.util.Map;

/**
 * @program: JefLogTail
 * @description: 使用mysql来存储
 * @author: Cheng Zhi
 * @create: 2023-03-05 12:45
 **/
public class SimpleDbAdapter extends AbstractLogSaveAdapter {

    Logger logger = LoggerFactory.getLogger(SimpleDbAdapter.class);

    @Override
    public void save(Message message) {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        IConnection connection = connectionFactory.getConnection(DBType.SIMPLEDB);
        connection.insert(message.getAttachment("ip"),message.getAttachment("fileName"), (String) message.getContent());
    }
}
